﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace E1_eMart.admin
{
    public partial class Products_Perchased : System.Web.UI.Page
    {
        protected List<SanPham> listSP = new List<SanPham>();

        protected void Page_Load(object sender, EventArgs e)
        {
            DataClasses1DataContext edata = new DataClasses1DataContext();
            List<SanPham> list = edata.SanPhams.ToList<SanPham>();
            for (int i = 0; i < list.Count; i++)
            {
                if (IsHetHan(list[i]))
                {
                    listSP.Add(list[i]);
                }
            }
        }

        private Boolean IsHetHan(SanPham sp)
        {
            DateTime dateNow = DateTime.Now;
            int thisyear = dateNow.Year;
            int thismonth = dateNow.Month;
            int thisday = dateNow.Day;

            int year = sp.NgayHetHan.Value.Year;
            int month = sp.NgayHetHan.Value.Month;
            int day = sp.NgayHetHan.Value.Day;
            if (thisyear < year)
                return false;
            else if (thisyear == year && thismonth < month)
                return false;
            else if (thisyear == year && thismonth == month && thisday < day)
                return false;
            return true;

        }
    }
}